package io.gitee.tianhaoran.chat.sdk.provider;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;
import io.gitee.tianhaoran.chat.sdk.provider.chatgpt.model.ChatgptImageRequest;
import lombok.experimental.UtilityClass;
import io.gitee.tianhaoran.chat.sdk.api.entity.chat.CompletionRequest;
import io.gitee.tianhaoran.chat.sdk.api.entity.image.ImageRequest;
import io.gitee.tianhaoran.chat.sdk.provider.chatgpt.model.ChatgptCompletionRequest;

/**
 * 转换器
 * <p>
 * 作者：沈自在
 **/
@UtilityClass
public class Convertor {

    /**
     * Copy选项
     */
    private static final CopyOptions Default_Copy_Options;

    // init
    static {
        Default_Copy_Options = new CopyOptions();
        Default_Copy_Options.ignoreNullValue();
    }

    /**
     * 转换为Chatgpt请求对象
     */
    public static ChatgptCompletionRequest toGptRequestWithChat(CompletionRequest request) {
        ChatgptCompletionRequest target = new ChatgptCompletionRequest();
        BeanUtil.copyProperties(request, target, Default_Copy_Options);
        return target;
    }

    public static ChatgptImageRequest toGptRequestWithImage(ImageRequest request){
        ChatgptImageRequest target = new ChatgptImageRequest();
        BeanUtil.copyProperties(request, target, Default_Copy_Options);
        return target;
    }
}
